<template>
  <div class="hello">
    <van-cell-group>
      <van-field
          v-model="username"
          required
          clearable
          label="用户名"
          icon="question"
          placeholder="请输入用户名"
          @click-icon="$toast('question')"
      />

      <van-field
          v-model="password"
          required
          type="password"
          label="密码"
          placeholder="请输入密码"
      />
    </van-cell-group>
    <van-button type="primary" @click="login"> 获取数据 </van-button>
  </div>
</template>

<script>
import { login, getChildren } from '@/request/api';

export default {
  name: 'HelloWorld',
  props: {
    msg: String,
  },
  data() {
    return {
      username: '13033202585',
      password: '666888',
    };
  },
  created() {
    this.onLoad();
  },
  methods: {
    onLoad() {
      console.log('页面加载成功');
    },

    login() {
      login({
        username: this.username,
        password: this.password,
        imageId: 'bedccd80-db23-11e8-a892-35905666f283',
        imageCode: 7,
      }).then((res) => {
        console.log(res);
        // localStorage.setItem('token', res.data.token);
      });
    },

    getChildren() {
      getChildren({
        childId: '1',
      }).then((res) => {
        console.log(res);
      });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
